//package com.matt.components.MQ;
//
//import com.aliyun.openservices.ons.api.Action;
//import com.aliyun.openservices.ons.api.ConsumeContext;
//import com.aliyun.openservices.ons.api.Message;
//import com.aliyun.openservices.ons.api.MessageListener;
//import com.matt.commons.constant.MQConstant;
//import com.matt.foundation.ext.mq.MQConsumer;
//import com.matt.service.MQMessageService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * *******************************
// * Created by Ron.
// * form com.matt
// * on 2018/10/24
// * *******************************
// */
//@Component
//@Slf4j
//public class NormalMessageListener implements MessageListener{
//
//
//    @Autowired
//    private MQConsumer mqConsumer;
//
//    @Autowired
//    private MQMessageService mqMessageService;
//
//
//    @Override
//    public Action consume(Message message, ConsumeContext context) {
//        try {
//            String content = new String(message.getBody(),"UTF-8");
//            Action action = mqConsumer.consume(message, content);
//            log.info("消息【{}】处理结束, 消费结果: [{}]", content, action.name());
//            return action;
//        }catch (UnsupportedEncodingException e){
//            log.info("消息处理失败, topic:[{}], tag:[{}], body:[{}]", message.getTopic(), message.getTag(),  new String(message.getBody()));
//            mqMessageService.saveAndRefresh(message, MQConstant.ConsumeStatus.FAILED.codeOf());
//            return Action.CommitMessage;
//        }
//
//    }
//
//
//}
